export default {
    ["common.navList"](state, list) {
        state.navList.list = list;
        list.forEach((item)=>{
            if(location.pathname == item.uri) {
                state.navList.activeCode = item.code;
                return;
            }
        })
    },
    // 存储用户信息
    ["common.user"](state, user) {
        state.user.token = user;
    },
    // 删除用户信息
    ["common.loginOut"](state) {
        state.user.token = null;
    },



    //删除面包屑导航信息  --无用
    ["common.removeCrumbTag"](state, index) {
        console.log(index)
        state.crumbData.list.forEach((item, tagIndex) => {
            if (item.index == index) {
                if (item.isActive == true) {
                    state.crumbData.list[tagIndex - 1].isActive = true;
                    state.crumbData.activeIndex = state.crumbData.list[tagIndex - 1].index;
                }
                state.crumbData.list.splice(tagIndex, 1);
            }
        })
    },
    //增加面包屑导航信息    --无用
    /*
    * @param
    *  object {
    *     index: 0,   非0，唯一
    *     text: "欢迎",   tab显示文字
    *     uri: "/index",    路由地址
    * }
    * */
    ["common.addCrumbTag"](state, object) {
        if (!object) {
            console.log("请传入合法数据");
            return;
        }

        let isInCrumb = false;
        state.crumbData.list.forEach((item) => {
            item.isActive = false;
            if (item.index == object.index) {
                isInCrumb = true;
                item.isActive = true;
                state.crumbData.activeIndex = object.index;
            }
        });
        if (!isInCrumb) {
            object.isActive = true;
            state.crumbData.list.push(object);
            state.crumbData.activeIndex = object.index;
        }
    },
    /*切换面包导航   --无用*/ 
    ["common.tabCrumbTag"](state, index) {
        state.crumbData.list.forEach((item) => {
            if(item.index == index) {
                item.isActive = true;
                state.crumbData.activeIndex = item.index;
            } else {
                item.isActive = false;
            }
        })
    },
    /* 设置面包导航 */ 
    ["common.setCrumb"](state, arr) {
        state.crumbData.list = arr;
    },
    // 存储左侧菜单数据
    ["common.subNavList"](state, list) {
        state.subNavList = list;
    },
    // 修改当前路由
    ["common.modifyCurNav"](state, curNav) {
        state.crumbData.curNav = curNav;
    }

}